package com.xjm.resource;

import org.springframework.core.io.FileSystemResource;

import java.io.*;

/**
 * @author jaymin
 * 2020/12/12 18:00
 */
public class FileSystemResourceDemo {
	public static void main(String[] args) throws IOException {
		FileSystemResource fileSystemResource = new FileSystemResource("D:\\Spring\\spring-framework-5.1.x\\spring-demo\\src\\main\\java\\com\\xjm\\resource\\test.txt");
		if (!fileSystemResource.exists()) {
			return;
		}
		try (OutputStream outputStream = fileSystemResource.getOutputStream();
			 BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream))) {
			bufferedWriter.append("I am using FileSystemResource of Spring");
			bufferedWriter.newLine();
			bufferedWriter.write("end.");
			bufferedWriter.flush();
		}
	}
}
